package com.theexceptions.todo.model;

/**
 * A filter that sorts tasks by whether or not they are completed.
 * 
 * @author Justian Meyer
 */
public class CompletedFilter implements TaskFilter {

	private boolean completed;

	/**
	 * Creates a filter to sort by whether or not a task is complete.
	 * 
	 * @param completed
	 */
	public CompletedFilter(boolean completed) {
		this.completed = completed;
	}

	@Override
	public String getQuery() {
		String column = DatabaseHelper.TASKS_COMPLETED;
		int c = (completed) ? 1 : 0;

		return String.format("%s = '%d'", column, c);
	}

}